<?php

namespace Part14_ObserverMode\Code1;

// 前台类
class Secretary
{
    // 查看股票的同事列表
    private $observers = [];
    private $action;

    // 请求前台观察老板的同事
    public function attach($observer)
    {
        $this->observers[] = $observer;
    }

    // 前台遍历通知同事
    public function notify()
    {
        foreach ($this->observers as $observer) {
            $observer->update();
        }
    }

    // 前台设置通知内容
    public function setAction($action)
    {
        $this->action = $action;
    }

    // 前台获取通知内容
    public function getAction()
    {
        return $this->action;
    }
}